<?php
class ui_reader_action_save extends ui {
	/**
	 * @param object $S
	 * @param array $param = array (
	 * 		article_type			// circle / feed / recommend / hot (save / save_on_edit 这两个应该不存在，是自己存档的)
	 * 		id				// 对应表中的主键id
	 * 		cn				// magic quote, encodeURIComponent
	 * 		cp				// is private
	 * 		f				// 好友uid字符串，用“,”连接
	 * 		c				// 圈子id字符串，用“,”连接
	 * )
	 */
	public function __construct($S, $param) {
		parent::__construct();
		
		if ($this->uid) {
			if ($param['cn']) {
				$param['cn'] = stripslashes(strip_tags(trim($param['cn'])));
				$param['cp'] = ($param['cp']) ? 'private' : 'public';
				$data_circle = new data_circle();
				$circle_id = $data_circle->add($this->uid, $param['cn'], $param['cp']);
				$param['c'] .= $circle_id;		// 附加最新的circle id，原来的结尾会有一个“,”
			}
			
			$data_save_article = new data_save_article();
			$insert_id = $data_save_article->in_site_save($this->uid, $param['article_type'], $param['id'], $param['f'], $param['c']);
			
			if ($insert_id) {
				$S->assign('data', 	'true');
			} else {
				$S->assign('data', 	'false');
			}
		}
	}
}
?>